<template>
  <div class="dashboard-editor-container">
    <template v-if="showChart">
      <!-- <panel-group :sumtotal="sumtotal" :OneDaytotal="OneDaytotal" /> -->
      <el-row style="background:#fff;padding:16px 16px 0;margin-bottom:32px;">
        <!-- <line-chart :chart-data="lineChartData" /> -->
      </el-row>
    </template>
    <template v-else>
      <div class="row  border-bottom white-bg dashboard-header">
        <div class="col-sm-12">
          <blockquote style="font-size:16px; line-height: 50px;">
            <div class="col-sm-3">
              <h2 style="color: orange;">Hello&nbsp;&nbsp;&nbsp;{{user.realName}}</h2>
              <div style="display: flex; margin-top: 10px;">
                <h3>欢迎您登录【AI保-管理后台】</h3>
                <h4>{{user.roleName}}</h4>
              </div>
              <br>
            </div>
            <div class="col-sm-5">
              <h3>
                记录下你的今天吧
                那些让你喜笑颜开的
                那些让你眉头紧皱的
                拥有美好心情的一天
              </h3>
            </div>
          </blockquote>
          <hr>
        </div>
      </div>
    </template>
  </div>
</template>

<script>
import storage from 'store'
// import LineChart from '@/views/dashboard/editor/lineChart'
// import { search, getsumtotal, getOneDaytotal,getCustype } from '@/api/admin/platform/home/index'
// import { getElements } from 'utils/auth';
// import { findUserAndRole } from '../../../api/admin/employees/index'
export default {
  name: 'DashboardAdmin',
  // components: {
  //   LineChart
  // },
  data() {
    return {
      lineChartData: {
        expectedData: [],
        actualData: []
      },
      sumtotal: {
        companyCount: 0,
        customerCount: 0,
        userCount: 0
      },
      OneDaytotal: {
        oneDayCustomerCount: 0,
        oneDayUserActive: 0,
        oneDayPayCount: 0
      },
      timer: undefined,
      showChart: undefined,
      user: {},
    }
  },
  computed: {

  },
  created() {
    this.user.realName = storage.get('userName') || ''
    // var element = JSON.parse(getElements())
    // this.showChart = element['dashboard:showChart']
    // if (this.showChart) {
    //   this.search()
    //   this.getCardVal()
    // } else {
    //   // findUserAndRole().then(res => {
    //   //   this.user = res
    //   // });
    // }
  },
  methods: {
    // 获取六个月的平台收款
    search() {
      // search().then(res => {
      //   if (res.code === 0) {
      //     var list = res.data
      //     var months = list.map(item => { return item.month })
      //     var money = list.map(item => {
      //       if (item.money === null || item.money === 'null') {
      //         item.money = 0
      //       }
      //       return item.money
      //     })
      //     this.lineChartData.expectedData = months
      //     this.lineChartData.actualData = money
      //   }
      // })
    },
    getCardVal() {
      // setInterval(() => {
      //   setTimeout(() => {
      this.getsumtotal()
      this.getOneDaytotal()
      //   }, 0)
      // }, 5000)
    },
    //获取公司总数 用户数客户数 总客户数
    getsumtotal() {
      // getsumtotal().then(res => {
      //   if (res.code === 0) {
      //     this.sumtotal.companyCount = res.companyCount ? res.companyCount : 0
      //     this.sumtotal.customerCount = res.customerCount ? res.customerCount : 0
      //     this.sumtotal.userCount = res.userCount ? res.userCount : 0
      //   }
      // })
    },
    //获取当日活用户数 日增商机数 日增收款
    getOneDaytotal() {
      // getOneDaytotal().then(res => {
      //   if (res.code === 0) {
      //     this.OneDaytotal.oneDayCustomerCount = res.oneDayCustomerCount ? res.oneDayCustomerCount : 0
      //     this.OneDaytotal.oneDayUserActive = res.oneDayUserActive ? res.oneDayUserActive : 0
      //     this.OneDaytotal.oneDayPayCount = res.oneDayPayCount ? res.oneDayPayCount : 0
      //   }
      // })
    },
    showtime() {
      var timerID = null;
      var timerRunning = false;
      var timeValue;
      var now = new Date();
      var hours = now.getHours();
      var minutes = now.getMinutes();
      var seconds = now.getSeconds()
      timeValue = "" + ((hours >= 12) ? "晚上好" : "上午好")
      this.date = timeValue
      console.log(timeValue)
      document.clock.thetime.value = this.date;
      timerID = setTimeout("showtime()", 1000);
      timerRunning = true;
    },
    // 获取品牌品类
    getCustype(){
      // getCustype().then(res=>{
      //   if (res.success) {
      //     window.localStorage.setItem('custypeList', JSON.stringify(res.brandsCustypeList))    
      //   }
      // }).catch(err=>{
      //   console.log(err);
      // })
    }
  },
  mounted(){
    this.getCustype()
  }
}
</script>

<style lang="less" scoped>
.dashboard-editor-container {
  padding: 32px;
  position: relative;

  .github-corner {
    position: absolute;
    top: 0px;
    border: 0;
    right: 0;
  }

  .chart-wrapper {
    background: #fff;
    padding: 16px 16px 0;
    margin-bottom: 32px;
  }
}

/* 底部 */
.mxg-footer {
  margin-top: 317px;
  padding-top: 60px !important;
  padding-bottom: 50px !important;
  background: #fff;
}

.mxg-footer .warp {
  max-width: 1190px;
  margin: 0 auto;
}

.mxg-footer .warp .top-line {
  width: 1000px;
  height: 1px;
  background: #e3ebf0;
  margin: 0 auto;
}

.mxg-footer .warp .footer-link {
  height: 18px;
  line-height: 18px;
  text-align: center;
  margin-top: 40px;
  font-family: PingFangSC-Regular;
  font-size: 16px;
}

.mxg-footer .warp .footer-link a {
  display: inline-block;
  color: #2c2c40;
}

.mxg-footer .warp .footer-link span {
  display: inline-block;
  color: #2c2c40;
  padding: 0 10px;
}

.mxg-footer .warp .footer-information-box {
  font-family: PingFangSC-Regular;
  text-align: center;
  margin: 30px 0;
  font-size: 12px;
  line-height: 12px;
  color: #2c2c40;
}

.mxg-footer .warp .footer-information-box a {
  color: #2c2c40;
}
.total-layout {
  margin-top: 20px;
}
.total-frame {
  border: 1px solid #dcdfe6;
  padding: 20px;
  height: 100px;
}
.total-icon {
  color: #409eff;
  width: 60px;
  height: 60px;
}
.total-title {
  position: relative;
  font-size: 16px;
  color: #909399;
  left: 70px;
  top: -50px;
}
.total-value {
  position: relative;
  font-size: 18px;
  color: #606266;
  left: 70px;
  top: -40px;
}
.un-handle-layout {
  margin-top: 20px;
  border: 1px solid #dcdfe6;
}
.layout-title {
  color: #606266;
  padding: 15px 20px;
  background: #f2f6fc;
  font-weight: bold;
}
</style>
